package com.example.lss.news;

import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;

import com.example.lss.news.utils.app.BaseActivity;

public class SplashActivity extends BaseActivity {
    private Handler handler = new Handler();


    @Override
    protected int getLayoutId() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        return R.layout.activity_splash;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i >= 0; i--) {
                    final int i1 = i;
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
//                    handler.post(new Runnable() {
//                        @Override
//                        public void run() {
//                            textView.setText("跳转" + i1 + "s");
//                        }
//                    });
                    if (i == 0) {
                        String s = getSP("head", null);
                        if (s == null) {
                            Intent it = new Intent(SplashActivity.this, LoginActivity.class);
                            startActivity(it);
                        }else {
                            Intent it = new Intent(SplashActivity.this, MainActivity.class);
                            startActivity(it);
                        }
                    }
                }
                finish();

            }
        }).start();
    }

    @Override
    protected void initListener() {

    }
}
